package com.ruicar.afs.cloud.apply.common.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruicar.afs.cloud.common.core.entity.BaseEntity;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;

/**
 * @author: Lee
 * @date: 2020/5/11 18:42
 * @description: 银行卡申请表
 */
@Data
@TableName(value = "apply_bank_card", autoResultMap = true)
@Accessors(chain = true)
public class ApplyBankCard extends BaseEntity<ApplyBankCard> {
    /**
     * 申请编号
     */
    private String applyNo;
    /**
     * 合同编号
     */
    private String contractNo;
    /**
     * 授权方式;电子授权/纸质授权
     */
    private String authorizeWay;
    /**
     * 开户银行
     */
    private String bankCode;
    /**
     * 开户银行
     */
    @TableField(exist = false)
    private String bankName;
    /**
     * 开户银行支行
     */
    private String bankBranch;
    /**
     * 开户名
     */
    private String accountName;
    /**
     * 开户卡号
     */
    private String accountNo;
    /**
     * 开户证件号码
     */
    private String certNo;
    /**
     * 卡预留手机号
     */
    private String bankPhone;
    /**
     * 签约验证码
     */
    private String verCode;
    /**
     * 签约状态
     */
    private String verStatus;
    /**
     * 开户省份
     */
    private String openProvince;
    /**
     * 开户城市
     */
    private String openCity;
    /**
     * 开户详细地址
     */
    private String openAddress;
    /**
     * 回显页面翻译用 开户地址
     */
    @TableField(exist = false)
    private String[] openAddressTemp;
    /**
     * 客户姓名
     */
    @TableField(exist = false)
    private String custName;
    /**
     * 证件类型
     */
    @TableField(exist = false)
    private String certTypeName;
    /**
     * 证件类型
     */
    @TableField(exist = false)
    private String certType;
    /**
     * 联系方式
     */
    @TableField(exist = false)
    private String certPhone;
    /**
     * 有效期截止日期
     */
    private String deadlineDate;

    public String[] getOpenAddressTemp() {
        if (StringUtils.isEmpty(this.openProvince) && StringUtils.isEmpty(this.openCity)) {
            return null;
        } else {
            return new String[]{this.openProvince, this.openCity};
        }
    }

    public void setOpenAddressTemp(String[] openAddressTemp) {
        if(openAddressTemp!=null){
            if (openAddressTemp.length >= 1) {
                this.openProvince = openAddressTemp[0];
            }
            if (openAddressTemp.length >= 2) {
                this.openCity = openAddressTemp[1];
            }
            this.openAddressTemp = openAddressTemp;
        }
    }
}
